<?php

/** @var \Illuminate\Database\Eloquent\Factory $factory */

use App\Models\Test\Test1;
use App\Models\Test\Test2;
use App\Models\Test\Test3;
use Faker\Generator as Faker;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/

$factory->define(Test2::class, function (Faker $faker) {
    return [
        'name' => $faker->word,
        'phone' => $faker->phoneNumber,
    ];
});

$factory->define(Test3::class, function (Faker $faker) {
    return [
        'name' => $faker->word,
        'phone' => $faker->phoneNumber,
    ];
});


$factory->define(Test1::class, function (Faker $faker) {
    $test2 = factory(Test2::class)->create();
    $test3 = factory(Test3::class)->create();

    return [
        'test2_id' => $test2->id,
        'test3_id' => $test3->id,
        'name' => $faker->word,
        'phone' => $faker->phoneNumber,
    ];
});